<div class="page dashboard">
    <div class="container">
        <div class="row">
                <ul class="span3 nav nav-list menu-sidebar">
                    <div style="margin-bottom:10px;" >Selamat Datang, <?php echo anchor(site_url('admin/dashboard'), $this->session->userdata('username')); ?></div>
                    <li class=""><?php echo anchor(site_url('admin/profil/form_update_user/'.$this->session->userdata('user_id')),'Edit Profil');?></li>
                    <li class="aktif"><?php echo anchor(site_url('admin/listing'),'Kelola Properti');?></li>
                    <?php if($level_user == 1){ ?>
                    <li class=""><?php echo anchor(site_url('admin/profil'),'Kelola Agen');?></li>
                    <li class=""><?php echo anchor(site_url('admin/artikel'),'Kelola Artikel');?></li>
                    <li class=""><?php echo anchor('http://localhost/artyproperty/editor/properti_baru.php','Kelola Properti Baru');?></li>
                    <?php } ?>
                </ul>
            <div class="span9 daftar-listing">
                <legend><h5>Daftar Properti</h5></legend>                    
                <?php

                $sewa_beli = '';
                $tipe = '';

                //if ($this->session->userdata('level') == '1') {
                    echo anchor('admin/listing/tambah_listing_infodasar', 'Tambah Properti');
                //}

                if ($daftar_listing != null) { ?>
                    <!-- //$this->table->set_heading('id', 'nama', 'tipe', 'luas bangunan', 'kmr tidur', 'kmr mandi', 'harga', 'sewa/beli', 'ubah', 'hapus'); -->
                <table class="table table-striped" style="font-size:12px;">
                        <thead>
                            <tr>
                                <th>ID</th>
                                <th>Nama</th>
                                <th>Tipe</th>
                                <th>Luas Bangunan</th>
                                <th>Harga</th>
                                <th>Sewa/Beli</th>
                                <th>Ubah/Hapus</th>
                            </tr>
                        </thead>    
                        <tbody>
                            
                <?php    foreach ($daftar_listing->result() as $key => $val) {
                        $modify_link = anchor('admin/listing/form_update_listing/' . $val->properti_id, 'ubah');
                        //$delete_link = anchor('admin/listing/hapus_listing/' . $val->properti_id, 'hapus');
                        if ($val->sewa_beli == 1) {
                            $sewa_beli = 'beli';
                        } else {
                            $sewa_beli = 'sewa';
                        }

                        if ($val->tipe == 1) {
                            $tipe = 'rumah';
                        } else {
                            $tipe = 'apartemen';
                        } ?>
                        <tr>
                                <td><?php echo $val->properti_id; ?></td>
                                <td><?php echo anchor('listing/detail/'.$val->properti_id,$val->nama_properti); ?></td>
                                <td><?php echo $tipe; ?></td>
                                <td><?php echo $val->luas_bangunan; ?> m<sup>2</sup></td>
                                <td><?php echo $val->harga; ?></td>
                                <td><?php echo $sewa_beli;?></td>
                                <td><?php echo $modify_link; ?>|<a href="<?php echo site_url('admin/listing/hapus_listing/' . $val->properti_id); ?>" onclick="return confirm('Apakah Anda yakin untuk menghapusnya?');">hapus</a></td>
                            </tr>
                 <?php   } ?> 
                    <!-- //echo $this->table->generate(); -->
                </tbody>
            </table>
                <?php } else {
                    echo '</br>daftar properti kosong</br>';
                }
                ?>
            </div>
    </div>
</div>
</div>